package lily.phs.object;

import lily.phs.database.Constants;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;


public class PostnatalVisit implements Constants{
	
	private Context mContext;
	
	private int povi_id=-1;
	private String povi_date="";
	private float povi_body_temprature=-1f;
	private String povi_ordinary_healthstatus="";
	private String povi_ordinary_mentalstatus="";
	private int povi_bloodpressure_high=-1;
	private int povi_bloodpressure_low=-1;
	private int povi_has_breast_abnormal=-1;
	private String povi_breast_abnormal="";
	private int povi_has_lochia_abnormal=-1;
	private String povi_lochia_abnormal="";
	private int povi_has_uterus_abnormal=-1;
	private String povi_uterus_abnormal="";
	private int povi_has_wound_abnormal=-1;
	private String povi_wound_abnormal="";
	private String povi_other_abnormal="";
	private int povi_is_abnormal=-1;
	private String povi_abnormal="";
	private String povi_guide="";
	private String povi_other_guide="";
	private int povi_need_transfer=-1;
	private String povi_transfer_reason="";
	private String povi_transfer_hospital="";
	private String povi_next_visit_date="";
	private String povi_doctor="";
	
	public PostnatalVisit(Context context){
		this.mContext = context;
	}

	public int getPovi_id() {
		return povi_id;
	}

	public void setPovi_id(int povi_id) {
		this.povi_id = povi_id;
	}

	public String getPovi_date() {
		return povi_date;
	}

	public void setPovi_date(String povi_date) {
		this.povi_date = povi_date;
	}

	public float getPovi_body_temprature() {
		return povi_body_temprature;
	}

	public void setPovi_body_temprature(float povi_body_temprature) {
		this.povi_body_temprature = povi_body_temprature;
	}

	public String getPovi_ordinary_healthstatus() {
		return povi_ordinary_healthstatus;
	}

	public void setPovi_ordinary_healthstatus(String povi_ordinary_healthstatus) {
		this.povi_ordinary_healthstatus = povi_ordinary_healthstatus;
	}

	public String getPovi_ordinary_mentalstatus() {
		return povi_ordinary_mentalstatus;
	}

	public void setPovi_ordinary_mentalstatus(String povi_ordinary_mentalstatus) {
		this.povi_ordinary_mentalstatus = povi_ordinary_mentalstatus;
	}

	public int getPovi_bloodpressure_high() {
		return povi_bloodpressure_high;
	}

	public void setPovi_bloodpressure_high(int povi_bloodpressure_high) {
		this.povi_bloodpressure_high = povi_bloodpressure_high;
	}

	public int getPovi_bloodpressure_low() {
		return povi_bloodpressure_low;
	}

	public void setPovi_bloodpressure_low(int povi_bloodpressure_low) {
		this.povi_bloodpressure_low = povi_bloodpressure_low;
	}

	public int getPovi_has_breast_abnormal() {
		return povi_has_breast_abnormal;
	}

	public void setPovi_has_breast_abnormal(int povi_has_breast_abnormal) {
		this.povi_has_breast_abnormal = povi_has_breast_abnormal;
	}

	public String getPovi_breast_abnormal() {
		return povi_breast_abnormal;
	}

	public void setPovi_breast_abnormal(String povi_breast_abnormal) {
		this.povi_breast_abnormal = povi_breast_abnormal;
	}

	public int getPovi_has_lochia_abnormal() {
		return povi_has_lochia_abnormal;
	}

	public void setPovi_has_lochia_abnormal(int povi_has_lochia_abnormal) {
		this.povi_has_lochia_abnormal = povi_has_lochia_abnormal;
	}

	public String getPovi_lochia_abnormal() {
		return povi_lochia_abnormal;
	}

	public void setPovi_lochia_abnormal(String povi_lochia_abnormal) {
		this.povi_lochia_abnormal = povi_lochia_abnormal;
	}

	public int getPovi_has_uterus_abnormal() {
		return povi_has_uterus_abnormal;
	}

	public void setPovi_has_uterus_abnormal(int povi_has_uterus_abnormal) {
		this.povi_has_uterus_abnormal = povi_has_uterus_abnormal;
	}

	public String getPovi_uterus_abnormal() {
		return povi_uterus_abnormal;
	}

	public void setPovi_uterus_abnormal(String povi_uterus_abnormal) {
		this.povi_uterus_abnormal = povi_uterus_abnormal;
	}

	public int getPovi_has_wound_abnormal() {
		return povi_has_wound_abnormal;
	}

	public void setPovi_has_wound_abnormal(int povi_has_wound_abnormal) {
		this.povi_has_wound_abnormal = povi_has_wound_abnormal;
	}

	public String getPovi_wound_abnormal() {
		return povi_wound_abnormal;
	}

	public void setPovi_wound_abnormal(String povi_wound_abnormal) {
		this.povi_wound_abnormal = povi_wound_abnormal;
	}

	public String getPovi_other_abnormal() {
		return povi_other_abnormal;
	}

	public void setPovi_other_abnormal(String povi_other_abnormal) {
		this.povi_other_abnormal = povi_other_abnormal;
	}

	public int getPovi_is_abnormal() {
		return povi_is_abnormal;
	}

	public void setPovi_is_abnormal(int povi_is_abnormal) {
		this.povi_is_abnormal = povi_is_abnormal;
	}

	public String getPovi_abnormal() {
		return povi_abnormal;
	}

	public void setPovi_abnormal(String povi_abnormal) {
		this.povi_abnormal = povi_abnormal;
	}

	public String getPovi_guide() {
		return povi_guide;
	}

	public void setPovi_guide(String povi_guide) {
		this.povi_guide = povi_guide;
	}

	public String getPovi_other_guide() {
		return povi_other_guide;
	}

	public void setPovi_other_guide(String povi_other_guide) {
		this.povi_other_guide = povi_other_guide;
	}

	public int getPovi_need_transfer() {
		return povi_need_transfer;
	}

	public void setPovi_need_transfer(int povi_need_transfer) {
		this.povi_need_transfer = povi_need_transfer;
	}

	public String getPovi_transfer_reason() {
		return povi_transfer_reason;
	}

	public void setPovi_transfer_reason(String povi_transfer_reason) {
		this.povi_transfer_reason = povi_transfer_reason;
	}

	public String getPovi_transfer_hospital() {
		return povi_transfer_hospital;
	}

	public void setPovi_transfer_hospital(String povi_transfer_hospital) {
		this.povi_transfer_hospital = povi_transfer_hospital;
	}

	public String getPovi_next_visit_date() {
		return povi_next_visit_date;
	}

	public void setPovi_next_visit_date(String povi_next_visit_date) {
		this.povi_next_visit_date = povi_next_visit_date;
	}

	public String getPovi_doctor() {
		return povi_doctor;
	}

	public void setPovi_doctor(String povi_doctor) {
		this.povi_doctor = povi_doctor;
	}
	
	public void insertPostnatalVisit(){
//		int result = -1;
		ContentValues value = new ContentValues();
		value.put(POVI_COLUMN1, this.getPovi_id());
		value.put(POVI_COLUMN2, this.getPovi_date());
		value.put(POVI_COLUMN3, this.getPovi_body_temprature());
		value.put(POVI_COLUMN4, this.getPovi_ordinary_healthstatus());
		value.put(POVI_COLUMN5, this.getPovi_ordinary_mentalstatus());
		value.put(POVI_COLUMN6, this.getPovi_bloodpressure_high());
		value.put(POVI_COLUMN7, this.getPovi_bloodpressure_low());
		value.put(POVI_COLUMN8, this.getPovi_has_breast_abnormal());
		value.put(POVI_COLUMN9, this.getPovi_breast_abnormal());
		value.put(POVI_COLUMN10, this.getPovi_has_lochia_abnormal());
		value.put(POVI_COLUMN11, this.getPovi_lochia_abnormal());
		value.put(POVI_COLUMN12, this.getPovi_has_uterus_abnormal());
		value.put(POVI_COLUMN13, this.getPovi_uterus_abnormal());
		value.put(POVI_COLUMN14, this.getPovi_has_wound_abnormal());
		value.put(POVI_COLUMN15, this.getPovi_wound_abnormal());
		value.put(POVI_COLUMN16, this.getPovi_other_abnormal());
		value.put(POVI_COLUMN17, this.getPovi_is_abnormal());
		value.put(POVI_COLUMN18, this.getPovi_abnormal());
		value.put(POVI_COLUMN19, this.getPovi_guide());
		value.put(POVI_COLUMN20, this.getPovi_other_guide());
		value.put(POVI_COLUMN21, this.getPovi_need_transfer());
		value.put(POVI_COLUMN22, this.getPovi_transfer_reason());
		value.put(POVI_COLUMN23, this.getPovi_transfer_hospital());
		value.put(POVI_COLUMN24, this.getPovi_next_visit_date());
		value.put(POVI_COLUMN25, this.getPovi_doctor());
		
		mContext.getContentResolver().insert(CONTENT_URI_TB18, value);
//		return result;
		
	}
	
	public void selectPostnatalVisit(int id){
		String where = POVI_COLUMN1 + "=" + id + "";
		Cursor cursor = mContext.getContentResolver().query(CONTENT_URI_TB18, null, where, null, null);
		while(cursor.moveToNext()){
			this.povi_id = cursor.getInt(cursor.getColumnIndex(POVI_COLUMN1));
			this.povi_date = cursor.getString(cursor.getColumnIndex(POVI_COLUMN2));
			this.povi_body_temprature = cursor.getFloat(cursor.getColumnIndex(POVI_COLUMN3));
			this.povi_ordinary_healthstatus = cursor.getString(cursor.getColumnIndex(POVI_COLUMN4));
			this.povi_ordinary_mentalstatus = cursor.getString(cursor.getColumnIndex(POVI_COLUMN5));
			this.povi_bloodpressure_high = cursor.getInt(cursor.getColumnIndex(POVI_COLUMN6));
			this.povi_bloodpressure_low = cursor.getInt(cursor.getColumnIndex(POVI_COLUMN7));
			this.povi_has_breast_abnormal = cursor.getInt(cursor.getColumnIndex(POVI_COLUMN8));
			this.povi_breast_abnormal = cursor.getString(cursor.getColumnIndex(POVI_COLUMN9));
			this.povi_has_lochia_abnormal = cursor.getInt(cursor.getColumnIndex(POVI_COLUMN10));
			this.povi_lochia_abnormal = cursor.getString(cursor.getColumnIndex(POVI_COLUMN11));
			this.povi_has_uterus_abnormal = cursor.getInt(cursor.getColumnIndex(POVI_COLUMN12));
			this.povi_uterus_abnormal = cursor.getString(cursor.getColumnIndex(POVI_COLUMN13));
			this.povi_has_wound_abnormal = cursor.getInt(cursor.getColumnIndex(POVI_COLUMN14));
			this.povi_wound_abnormal = cursor.getString(cursor.getColumnIndex(POVI_COLUMN15));
			this.povi_other_abnormal = cursor.getString(cursor.getColumnIndex(POVI_COLUMN16));
			this.povi_is_abnormal = cursor.getInt(cursor.getColumnIndex(POVI_COLUMN17));
			this.povi_abnormal = cursor.getString(cursor.getColumnIndex(POVI_COLUMN18));
			this.povi_guide = cursor.getString(cursor.getColumnIndex(POVI_COLUMN19));
			this.povi_other_guide = cursor.getString(cursor.getColumnIndex(POVI_COLUMN20));
			this.povi_need_transfer = cursor.getInt(cursor.getColumnIndex(POVI_COLUMN21));
			this.povi_transfer_reason = cursor.getString(cursor.getColumnIndex(POVI_COLUMN22));
			this.povi_transfer_hospital = cursor.getString(cursor.getColumnIndex(POVI_COLUMN23));
			this.povi_next_visit_date = cursor.getString(cursor.getColumnIndex(POVI_COLUMN24));
			this.povi_doctor = cursor.getString(cursor.getColumnIndex(POVI_COLUMN25));
			
		}
		cursor.close();
		
	}
	
	public void updatePostnatalVisit(int id){
		ContentValues value = new ContentValues();
		value.put(POVI_COLUMN1, this.getPovi_id());
		value.put(POVI_COLUMN2, this.getPovi_date());
		value.put(POVI_COLUMN3, this.getPovi_body_temprature());
		value.put(POVI_COLUMN4, this.getPovi_ordinary_healthstatus());
		value.put(POVI_COLUMN5, this.getPovi_ordinary_mentalstatus());
		value.put(POVI_COLUMN6, this.getPovi_bloodpressure_high());
		value.put(POVI_COLUMN7, this.getPovi_bloodpressure_low());
		value.put(POVI_COLUMN8, this.getPovi_has_breast_abnormal());
		value.put(POVI_COLUMN9, this.getPovi_breast_abnormal());
		value.put(POVI_COLUMN10, this.getPovi_has_lochia_abnormal());
		value.put(POVI_COLUMN11, this.getPovi_lochia_abnormal());
		value.put(POVI_COLUMN12, this.getPovi_has_uterus_abnormal());
		value.put(POVI_COLUMN13, this.getPovi_uterus_abnormal());
		value.put(POVI_COLUMN14, this.getPovi_has_wound_abnormal());
		value.put(POVI_COLUMN15, this.getPovi_wound_abnormal());
		value.put(POVI_COLUMN16, this.getPovi_other_abnormal());
		value.put(POVI_COLUMN17, this.getPovi_is_abnormal());
		value.put(POVI_COLUMN18, this.getPovi_abnormal());
		value.put(POVI_COLUMN19, this.getPovi_guide());
		value.put(POVI_COLUMN20, this.getPovi_other_guide());
		value.put(POVI_COLUMN21, this.getPovi_need_transfer());
		value.put(POVI_COLUMN22, this.getPovi_transfer_reason());
		value.put(POVI_COLUMN23, this.getPovi_transfer_hospital());
		value.put(POVI_COLUMN24, this.getPovi_next_visit_date());
		value.put(POVI_COLUMN25, this.getPovi_doctor());
		
		String where = POVI_COLUMN1 + "=" + id + " ";
		mContext.getContentResolver().update(CONTENT_URI_TB18, value, where, null);
		
	}
	
	public void delectPostnatalVisit(int id){
		String where = POVI_COLUMN1 + "=" + id + " ";
		mContext.getContentResolver().delete(CONTENT_URI_TB18, where, null);
		
	}

}
